<template>
    <div class="login">
        <h2 class="title">请先登录</h2>
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="账号">
                <el-input v-model="form.account"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="pass">
                <el-input type="password" v-model="form.password" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submit">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: "Login",
    data() {
        return {
            form: {
                account: "",
                region: ""
            }
        };
    },
    methods: {
        submit: async function() {
            // let postData = this.$qs.stringify({
            //     "account": this.form.account,
            //     "password": this.form.password
            // });

            // console.log(postData);
            let data = await this._axios
                .post(`/ycwAdmin/admin/login`, {
                "account": this.form.account,
                "password": this.form.password
            })
                .then(data => data);
            console.log(data);
            
            // if(data.data.data[0].token){
            //   localStorage.setItem('token',data.data.data[0].token);
            //   this.$store.commit('saveUserInfo', data.data.data[0]);
            //   this.$router.push('ycw_admin/home_ycw');
            // }
            // console.log(data);
            this.$router.push('ycwAdmin/main');
        }
    }
};
</script>

<style lang="scss" scoped>
    .login{
        max-width: 100%;
        width: 600px;
        margin: 0 auto;
        position: relative;
        top:50vh;
        transform:translateY(-50%);
        .title{
            text-align: left;
            margin-left: 40px;
        }
    }
    
</style>